﻿using HZU.ZP.Data.Interfaces.Resume;
using HZU.ZP.Data.Models;
using HZU.ZP.Data.Models.Resume;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HZU.ZP.Data.Impl.Resume
{
    public class EducationExperienceDao:IEducationExperienceDao
    {
        private EFCoreDbContext _context;

        public EducationExperienceDao(EFCoreDbContext context)
        {
            _context = context;
        }

        public void AddEducationExperience(EducationExperience educationExperience)
        {
            _context.EducationExperiences.Add(educationExperience);
            _context.SaveChanges();
        }

        public void DeleteEducationExperience(int id)
        {
            var educationExperience = _context.EducationExperiences.FirstOrDefault(e => e.Id == id);
            _context.EducationExperiences.Remove(educationExperience);
            _context.SaveChanges();
        }

        public IList<EducationExperience> GetEducationExperienceList(int ApplicanId)
        {
            return _context.EducationExperiences.Where(e => e.ApplicantId == ApplicanId).ToList();
        }

        public void UpdateEducationExperience(EducationExperience educationExperience)
        {
            _context.EducationExperiences.Update(educationExperience);
            _context.SaveChanges();
        }
    }
}
